<?php
//初始化设置
header("content-type:text/html;charset=UTF-8");
session_start();

define("CT",1);
date_default_timezone_set('PRC');  //设置默认时区
define('ROOT_PATH',  str_replace('\\', '/', dirname(dirname(dirname(__FILE__))))."/");
define('PAGE_SIZE',  20);

//引入配置文件
$domain = $_SERVER["HTTP_HOST"];
@ini_set("session.cookie_domain", $domain);

require_once(ROOT_PATH."lib/db_init.php");//引入数据库文件
require_once(ROOT_PATH."lib/cls_smarty.php");//引入模板文件
require_once(ROOT_PATH."application/constant/Constant.php");

$smarty=new Smarty();

$smarty->template_dir   = ROOT_PATH . 'application/views/admin/';
$smarty->compile_dir    = ROOT_PATH . 'temp/compiled';

/*载入公共库文件*/
require_once(ROOT_PATH."lib/lib_base.php");
require_once(ROOT_PATH."lib/PageUtil.php");

//基本设置结束--------------


//读取系统设定
$setting = $db->getRow("select * from " . table("setting"));

//页面参数判断
$m = isset($_GET['m']) ? htmlspecialchars($_GET['m']) : "index";
$m = str_replace(array("/","\\"),"",$m);

if(!file_exists(ROOT_PATH . "application/action/admin/$m.php")) {
	$m="index";
}

require_once(ROOT_PATH . "application/action/admin/$m.php");

//---------------------------通用函数---------------------------//
//页面调用通用函数
function check_login() {
	if(!$_SESSION['web_admin'] || $_SESSION['web_admin']['domain'] != $_SERVER['HTTP_HOST']) {
		header("Location:admin.php?m=logout");
		exit();
	}
	return true;
}

function haspermission($m,$a)
{
	return true;
}

function getAction()
{
	return $a = get_post("a") ? get_post("a") :  "index";
}


?>